package com.ssy.lingxi.after.sale.model.constant;

import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;

/**
 * 维修内部状态枚举
 * @author 伍将
 * @date 2020/9/1
 * @version 2.0.0
 */
public enum RepairGoodsInnerStatusEnum {

    ALL(0, "所有状态", "", ""),
    /**
     * 待提交维修 - 1
     */
    TO_BE_SUBMIT(1, "待提交", "待提交", "待提交"),
    /**
     * 审核通过(提交) - 2
     */
    SUBMIT_VERIFY_PASSED(2, "待审核(一级)", "已提交", "审核通过(提交)"),
    /**
     * 审核不通过(提交)  - 9
     */
    SUBMIT_VERIFY_UN_PASSED(9, "审核不通过(提交) ", "已提交", "审核不通过(提交)"),
    /**
     * 审核通过(一级) - 3
     */
    VERIFY_STEP1_PASSED(3, "待审核(二级)", "已提交", "审核通过(一级)"),
    /**
     * 审核不通过(一级) - 10
     */
    VERIFY_STEP1_UN_PASSED(10, "审核不通过(一级)", "已提交", "审核不通过(一级)"),
    /**
     * 审核通过(二级) - 4
     */
    VERIFY_STEP2_PASSED(4, "待确认", "已提交", "审核通过(二级)"),
    /**
     * 审核不通过(二级) - 5
     */
    VERIFY_STEP2_UN_PASSED(5, "审核不通过(二级)", "已提交", "审核不通过(二级)"),
    /**
     * 审核通过(确认) - 6
     */
    CONFIRM_ACCEPT_APPLY(6, "已确认", "待确认售后完成", "审核通过(确认)"),
    /**
     * 审核不通过(确认) - 7
     */
    CONFIRM_UN_ACCEPT_APPLY(7, "已确认", "已提交", "审核不通过(确认)"),
    /**
     * 确认售后完成 - 8
     */
    CONFIRM_COMPLETE(8, "已确认售后完成", "已确认售后完成", "已确认售后完成");

    private final Integer code;
    private final String message;
    /**
     * 消费者描述
     */
    private final String consumerDescribe;
    /**
     * 供应者描述
     */
    private final String supplierDescribe;


    RepairGoodsInnerStatusEnum(Integer code, String message, String consumerDescribe, String supplierDescribe) {
        this.code = code;
        this.message = message;
        this.consumerDescribe = consumerDescribe;
        this.supplierDescribe = supplierDescribe;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return LanguageHolder.getName(this.getDeclaringClass(), this.getCode());
    }

    public String getConsumerDescribe() {
        return LanguageHolder.getName(this.getDeclaringClass().getSimpleName().concat(".consumerDescribe.").concat(this.getCode().toString()));
    }

    public String getSupplierDescribe() {
        return LanguageHolder.getName(this.getDeclaringClass().getSimpleName().concat(".supplierDescribe.").concat(this.getCode().toString()));
    }

    public static String getMessage(Integer code) {
        return Arrays.stream(RepairGoodsInnerStatusEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(ALL).getMessage();
    }

    public static RepairGoodsInnerStatusEnum getEnum(Integer code) {
        return Arrays.stream(RepairGoodsInnerStatusEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(ALL);
    }

    /**
     * 根据code查询描述
     * @param code code值
     * @param isSupplier 是否为消费者
     * @return 描述
     */
    public static String getDescribe(Integer code, Boolean isSupplier) {
        RepairGoodsInnerStatusEnum statusEnum = Arrays.stream(RepairGoodsInnerStatusEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(ALL);
        return (isSupplier ? statusEnum.getSupplierDescribe() : statusEnum.getConsumerDescribe());
    }
}